package com.ssy.lingxi.common.handler;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import com.ssy.lingxi.common.utils.Aes128Util;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

public class AesEncryptSerialize extends JsonSerializer<String>{

    @Override
    public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        String encrypt;
        try {
            encrypt = Aes128Util.aesEncrypt(value);
        } catch (Exception e) {
            encrypt = "";
        }
        gen.writeString(encrypt);
    }

}
